package com.bt.dmdb.model;

import java.sql.Blob;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import org.hibernate.annotations.Type;
import org.joda.time.LocalDateTime;
import com.bt.dmdb.json.converter.JsonDateDeserializer;
import com.bt.dmdb.json.converter.JsonDateSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Entity
@Table(name = "customer_document")
@SuppressWarnings("serial")
public class CustomerDocument implements java.io.Serializable {

    private Long id;
    private CustomerDetails customer;
    private Document doc;
    private String fileName;
    private Blob document;
    private int status;
    private String version;
    private LocalDateTime uploadedDate;
    private String makerName;
    private String filePath;
    
    private LoginUser createdBy;
   	private LoginUser updatedBy;
   	
   	private LocalDateTime creationDate;   	
   	private LocalDateTime modificationDate;	
    
    
    public CustomerDocument() {
    }

   

	public CustomerDocument(Long id) {
        this.id = id;
    }

    public CustomerDocument(Long id, String fileName) {
        this.id = id;
        this.fileName = fileName;
    }
    
    public CustomerDocument(Long id, CustomerDetails customer, Document doc,
			String fileName, Blob document, int status, String version,
			LocalDateTime uploadedDate, String makerName, String filePath,
			LoginUser createdBy, LoginUser updatedBy, LocalDateTime creationDate,
			LocalDateTime modificationDate) {
		super();
		this.id = id;
		this.customer = customer;
		this.doc = doc;
		this.fileName = fileName;
		this.document = document;
		this.status = status;
		this.version = version;
		this.uploadedDate = uploadedDate;
		this.makerName = makerName;
		this.filePath = filePath;
		this.createdBy = createdBy;
		this.updatedBy = updatedBy;
		this.creationDate = creationDate;
		this.modificationDate = modificationDate;
	}
   
    @Id
    //@GeneratedValue
    @GeneratedValue(generator = "customerDocumentIG", strategy = GenerationType.TABLE)
    @TableGenerator(name = "customerDocumentIG", table = "jpa_sequences", pkColumnName = "name", pkColumnValue = "CustomerDocument", allocationSize = 10, valueColumnName = "next_hi_value")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "client_id")
    public CustomerDetails getCustomer() {
        return customer;
    }

    public void setCustomer(CustomerDetails customer) {
        this.customer = customer;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "document_id")
    public Document getDoc() {
        return doc;
    }

    public void setDoc(Document doc) {
        this.doc = doc;
    }

    @Column(name = "file_name")
    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    @Column(name = "document")
    public Blob getDocument() {
        return document;
    }

    public void setDocument(Blob document) {
        this.document = document;
    }

    @Column(name = "status")
    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    @Column(name = "version")
    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    @Column(name = "maker_name")
    public String getMakerName() {
        return makerName;
    }

    public void setMakerName(String makerName) {
        this.makerName = makerName;
    }

    @Column(name = "uploaded_date")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    @JsonSerialize(using = JsonDateSerializer.class)
    @JsonDeserialize(using = JsonDateDeserializer.class)
    public LocalDateTime getUploadedDate() {
        return uploadedDate;
    }

    public void setUploadedDate(LocalDateTime uploadedDate) {
        this.uploadedDate = uploadedDate;
    }
    
    @Column(name = "filePath")
     public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }



	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "created_by")
	public LoginUser getCreatedBy() {
		return createdBy;
	}



	public void setCreatedBy(LoginUser createdBy) {
		this.createdBy = createdBy;
	}


	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "updated_by")
	public LoginUser getUpdatedBy() {
		return updatedBy;
	}



	public void setUpdatedBy(LoginUser updatedBy) {
		this.updatedBy = updatedBy;
	}


	@Column(name = "creation_date")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    @JsonSerialize(using = JsonDateSerializer.class)
    @JsonDeserialize(using = JsonDateDeserializer.class)
	public LocalDateTime getCreationDate() {
		return creationDate;
	}



	public void setCreationDate(LocalDateTime creationDate) {
		this.creationDate = creationDate;
	}


	@Column(name = "modification_date")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    @JsonSerialize(using = JsonDateSerializer.class)
    @JsonDeserialize(using = JsonDateDeserializer.class)
	public LocalDateTime getModificationDate() {
		return modificationDate;
	}



	public void setModificationDate(LocalDateTime modificationDate) {
		this.modificationDate = modificationDate;
	}
}
